background-color: alpha (@fg_color, 0.25);
border-color: @fg_color;
border-style: solid;
- border-width: 1;
+ border-width: 1px;
}
.tooltip,
background-color: @tooltip_bg_color;
color: @tooltip_fg_color;
border-color: @tooltip_fg_color;
- border-width: 1;
+ border-width: 1px;
border-style: solid;
}
.button,
.slider {
border-style: outset;
- border-width: 2;
+ border-width: 2px;
}
.button:active {
.trough {
background-color: darker (@bg_color);
border-style: inset;
- border-width: 1;
+ border-width: 1px;
padding: 0;
}
.entry {
border-style: inset;
- border-width: 2;
+ border-width: 2px;
background-color: @base_color;
color: @text_color;
}
border-color: shade (@selected_bg_color, 0.7);
color: @selected_fg_color;
border-style: outset;
- border-width: 1;
+ border-width: 1px;
}
GtkCheckButton:hover,
.cell.check, .cell.radio,
.cell.check:hover, .cell.radio:hover {
border-style: solid;
- border-width: 1;
+ border-width: 1px;
background-color: @base_color;
border-color: @fg_color;
}
.popup {
border-style: outset;
- border-width: 1;
+ border-width: 1px;
}
.viewport {
border-style: inset;
- border-width: 2;
+ border-width: 2px;
}
.notebook {
border-style: outset;
- border-width: 1;
+ border-width: 1px;
}
.frame {
border-style: inset;
- border-width: 1;
+ border-width: 1px;
}
GtkScrolledWindow.frame {
.menubar,
.toolbar {
border-style: outset;
- border-width: 1;
+ border-width: 1px;
}
.menu:hover,
}
GtkSpinButton.button {
- border-width: 1;
+ border-width: 1px;
}
.scale.slider:hover,
color: #fff;
}
GtkCalendar.view {
- border-width: 1;
+ border-width: 1px;
border-style: inset;
padding: 1;
}
GtkCalendar.header {
background-color: @bg_color;
border-style: outset;
- border-width: 2;
+ border-width: 2px;
}
GtkCalendar.highlight {
.spinbutton.button,
.spinbutton.button:focused {
background-color: transparent;
- border-width: 1 1 0 0;
+ border-width: 1px 1px 0 0;
border-style: none;
background-image: -gtk-win32-theme-part(spin, 1 1);
color: rgba(0, 0, 0, 0);
.spinbutton.button.bottom,
.spinbutton.button.bottom:focused {
- border-width: 0 1 1 0;
+ border-width: 0 1px 1px 0;
background-image: -gtk-win32-theme-part(spin, 2 1);
color: rgba(0, 0, 0, 0);
}
.notebook {
background-color: transparent;
- border-width: 1 3 2 2;
+ border-width: 1px 3px 2px 2px;
border-style: solid;
background-origin: padding-box;
background-clip: border-box;
if (G_UNLIKELY (!provider))
{
-
provider = gtk_css_provider_new ();
if (!_gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/gtk-default.css"))
{
return TRUE;
}
+static gboolean
+parse_border_width_really (GtkCssShorthandProperty *shorthand,
+ GValue *values,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GtkCssNumber numbers[4];
+ guint i;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (!_gtk_css_parser_has_number (parser))
+ break;
+
+ if (!_gtk_css_parser_read_number (parser,
+ &numbers[i],
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
+ }
+
+ if (i == 0)
+ {
+ _gtk_css_parser_error (parser, "Expected a length");
+ return FALSE;
+ }
+
+ for (; i < 4; i++)
+ {
+ numbers[i] = numbers[(i - 1) >> 1];
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ g_value_init (&values[i], GTK_TYPE_CSS_NUMBER);
+ g_value_set_boxed (&values[i], &numbers[i]);
+ }
+
+ return TRUE;
+}
+
static gboolean
parse_border_radius (GtkCssShorthandProperty *shorthand,
GValue *values,
GtkCssParser *parser,
GFile *base)
{
- int width;
int style;
do
{
if (!G_IS_VALUE (&values[0]) &&
- _gtk_css_parser_try_length (parser, &width))
+ _gtk_css_parser_has_number (parser))
{
- g_value_init (&values[0], G_TYPE_INT);
- g_value_set_int (&values[0], width);
+ GtkCssNumber number;
+ if (!_gtk_css_parser_read_number (parser,
+ &number,
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
+
+ g_value_init (&values[0], GTK_TYPE_CSS_NUMBER);
+ g_value_set_boxed (&values[0], &number);
}
else if (!G_IS_VALUE (&values[1]) &&
_gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &style))
GtkCssParser *parser,
GFile *base)
{
- int width;
int style;
do
{
if (!G_IS_VALUE (&values[0]) &&
- _gtk_css_parser_try_length (parser, &width))
+ _gtk_css_parser_has_number (parser))
{
- g_value_init (&values[0], G_TYPE_INT);
- g_value_init (&values[1], G_TYPE_INT);
- g_value_init (&values[2], G_TYPE_INT);
- g_value_init (&values[3], G_TYPE_INT);
- g_value_set_int (&values[0], width);
- g_value_set_int (&values[1], width);
- g_value_set_int (&values[2], width);
- g_value_set_int (&values[3], width);
+ GtkCssNumber number;
+ if (!_gtk_css_parser_read_number (parser,
+ &number,
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
+
+ g_value_init (&values[0], GTK_TYPE_CSS_NUMBER);
+ g_value_init (&values[1], GTK_TYPE_CSS_NUMBER);
+ g_value_init (&values[2], GTK_TYPE_CSS_NUMBER);
+ g_value_init (&values[3], GTK_TYPE_CSS_NUMBER);
+ g_value_set_boxed (&values[0], &number);
+ g_value_set_boxed (&values[1], &number);
+ g_value_set_boxed (&values[2], &number);
+ g_value_set_boxed (&values[3], &number);
}
else if (!G_IS_VALUE (&values[4]) &&
_gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &style))
_gtk_css_shorthand_property_register ("border-width",
GTK_TYPE_BORDER,
border_width_subproperties,
- parse_border_width,
+ parse_border_width_really,
unpack_border,
pack_border);
_gtk_css_shorthand_property_register ("border-radius",
#include <gobject/gvaluecollector.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo-gobject.h>
+#include <math.h>
#include "gtkcssparserprivate.h"
#include "gtkcssstylefuncsprivate.h"
#include "gtkprivatetypebuiltins.h"
#include "gtkstylepropertiesprivate.h"
+/* this is in case round() is not provided by the compiler,
+ * such as in the case of C89 compilers, like MSVC
+ */
+#include "fallback-c89.c"
+
/* the actual parsers we have */
#include "gtkanimationdescription.h"
#include "gtkbindings.h"
g_value_take_object (computed, image);
}
+static gboolean
+parse_border_width (GtkCssStyleProperty *property,
+ GValue *value,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GtkCssNumber number;
+
+ if (!_gtk_css_parser_read_number (parser,
+ &number,
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
+
+ g_value_set_boxed (value, &number);
+ return TRUE;
+}
+
static void
compute_border_width (GtkCssStyleProperty *property,
GValue *computed,
{
GtkCssStyleProperty *style;
GtkBorderStyle border_style;
+ GtkCssNumber number;
/* The -1 is magic that is only true because we register the style
* properties directly after the width properties.
if (border_style == GTK_BORDER_STYLE_NONE ||
border_style == GTK_BORDER_STYLE_HIDDEN)
- g_value_set_int (computed, 0);
- else
- g_value_copy (specified, computed);
+ {
+ g_value_set_int (computed, 0);
+ return;
+ }
+
+ _gtk_css_number_compute (&number,
+ g_value_get_boxed (specified),
+ context);
+ g_value_set_int (computed, round (number.value));
}
static gboolean
_gtk_css_style_property_init_properties (void)
{
char *default_font_family[] = { "Sans", NULL };
+ GtkCssNumber number;
GtkSymbolicColor *symbolic;
GtkCssBorderCornerRadius no_corner_radius = { 0, };
GtkBorder border_of_ones = { 1, 1, 1, 1 };
NULL,
NULL,
0);
+ _gtk_css_number_init (&number, 0, GTK_CSS_PX);
/* IMPORTANT: compute_border_width() requires that the border-width
* properties be immeditaly followed by the border-style properties
*/
NULL,
GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-top-width",
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
G_TYPE_INT,
0,
- NULL,
+ parse_border_width,
NULL,
compute_border_width,
- 0);
+ &number);
gtk_css_style_property_register ("border-left-style",
GTK_TYPE_BORDER_STYLE,
GTK_TYPE_BORDER_STYLE,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-left-width",
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
G_TYPE_INT,
0,
- NULL,
+ parse_border_width,
NULL,
compute_border_width,
- 0);
+ &number);
gtk_css_style_property_register ("border-bottom-style",
GTK_TYPE_BORDER_STYLE,
GTK_TYPE_BORDER_STYLE,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-bottom-width",
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
G_TYPE_INT,
0,
- NULL,
+ parse_border_width,
NULL,
compute_border_width,
- 0);
+ &number);
gtk_css_style_property_register ("border-right-style",
GTK_TYPE_BORDER_STYLE,
GTK_TYPE_BORDER_STYLE,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-right-width",
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
G_TYPE_INT,
0,
- NULL,
+ parse_border_width,
NULL,
compute_border_width,
- 0);
+ &number);
gtk_css_style_property_register ("border-top-left-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("outline-width",
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
G_TYPE_INT,
0,
- NULL,
+ parse_border_width,
NULL,
compute_border_width,
- 0);
+ &number);
gtk_css_style_property_register ("outline-offset",
G_TYPE_INT,
G_TYPE_INT,